package com.lgx.mall.basic.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.lgx.common.entity.IdGenerator;
import com.lgx.common.web.util.DictUtils;
import com.lgx.right.entity.User;

/**
 * 收货地址
 * 
 * @author hezhuo
 *
 */
@Entity
@Table(name = "TM_ADDRESS")
public class Address implements Serializable{
	
	private static final long serialVersionUID = -1076292266863566942L;

	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TM_ADDRESS_ID)
	@TableGenerator(
			name = IdGenerator.TM_ADDRESS_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TM_ADDRESS_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	@ManyToOne
	@JoinColumn(name = "user_id")
	private User user;
	
	/**
	 * 联系人姓名
	 */
	private String name;
	
	/**
	 * 联系电话
	 */
	private String tel;
	
	/**
	 * 邮政编码
	 */
	private String zipcode;
	
	/**
	 * 所属省份
	 */
	private String province;
	
	/**
	 * 所属市
	 */
	private String city;
	
	/**
	 * 所属县、区
	 */
	private String region;
	
	/**
	 * 街道地址
	 */
	private String address;
	
	/**
	 * 是否为默认地址 1为默认地址 0否
	 */
	private Integer isdefault;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getZipcode() {
		return zipcode;
	}

	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Integer getIsdefault() {
		return isdefault;
	}

	public void setIsdefault(Integer isdefault) {
		this.isdefault = isdefault;
	}
	
	/**
	 * 完整收货地址
	 * @return
	 */
	public String getAddressAll(){
		return this.getProvince()+this.getCity()+this.getRegion()+this.address;
	}
	
	/**
	 * 是否默认地址
	 */
	public String IsDefaultAddress(){
		return DictUtils.getDictNameByKindAndCode(this.getIsdefault().toString(), DictUtils.DEFAULT_ADDRESS);
	}
}
